package com.market.product.dao;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Component;

import com.market.product.domain.ProductCommand;

@Component
public class ProductDaoImpl extends SqlSessionDaoSupport implements ProductDao{
	@Override
	public void insert(ProductCommand product) {
		getSqlSession().insert("insertProduct", product);
	}
	
	@Override
	public void update(ProductCommand product) {
		getSqlSession().update("updateProduct", product);		
	}
	
	@Override
	public void delete(int p_code) {
		getSqlSession().delete("deleteProduct", p_code);
	}
	
	@Override
	public int getRowCount(Map<String, Object> map) {
		return getSqlSession().selectOne("Product.selectCount", map);		
	}
	
	@Override
	public List<ProductCommand> list(Map<String, Object> map) {
		List<ProductCommand> list = getSqlSession().selectList("Product.selectList", map);
		return list;
	}
	
	@Override
	public ProductCommand select(int p_code) {
		ProductCommand product = getSqlSession().selectOne("Product.select", p_code);
		return product;
	}		
}
